using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace SPLogViewer
{
    static class Program
    {
        static MainForm mFrm;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            mFrm = new MainForm();
            if (args.Length > 0)
            {
                mFrm.LoadLogData(args[0]);
            }
            Application.Run(mFrm);
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            HandleException(e.Exception);
        }

     

        static void HandleException(Exception ex)
        {
            System.Diagnostics.EventLog el = new System.Diagnostics.EventLog("Application");
            el.Source = "SPLogViewer";
            string errorMessage = string.Format("{0} \r\n\r\n {1}", ex.Message, ex.StackTrace);
            el.WriteEntry(errorMessage, System.Diagnostics.EventLogEntryType.Error);
            MessageBox.Show(mFrm, ex.Message, "Ooooops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
}